<template>
  <div id="marketing">  
     <div  style="display:flex;align-items: center;">
            <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
            <div style="line-height: 40px;font-weight:bold:">营销账号</div>
     </div>

  <el-row>
        <el-col :span="24" style="text-align: right;">         
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="fictitious_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg2.png" />添加账号
            </el-button>         
        </el-col>
  </el-row>


   <!-- 渲染数据list -->
   <marketing-list :datalist="datalist" @up_list_fun="list_fun"> </marketing-list>

   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>


      <!-- 添加账号 -->
        <el-dialog title="添加账号" :visible.sync="fictitious_mtk"  width="500px">
            <div style="width:100%;"> 

           <el-form ref="form"  label-width="80px">  
                <el-row>   
                    <el-col :span="24" style="display:flex;">
                        <el-form-item label-width="0px" >
                            <el-input v-model="fictitious_form.phone" placeholder="手机号" class="search"></el-input>
                        </el-form-item>

                        <div class="custom_button" @click="fictitious_search()"></div>
                    </el-col>               
                </el-row>
                 <div style="width:100%;" v-if="fictitious_form.show"> 

                    <div style="display:flex;align-items: center;margin-top:10px;">       
                        <div class="box1" >帐号</div>
                        <div style="padding:0px 15px;"></div>
                        <div class="box1" >所属团队</div>
                    </div>

                    <div style="display:flex;align-items: center;margin-top:10px;">
                     
                    <div class="box">
                     
                        <img  v-if="conter.self_icon"  style="width: 50px; height: 50px" :src="urlimg + conter.self_icon" /> 
                           <img  v-else src="@/assets/images/login_bg1.png" />
                        <div class="box_item">
                            <span>{{ conter.self_username }}</span>
                            <span>{{ conter.self_telphone }}</span>
                        </div>
                    </div>

                    <div style="padding:0px 15px;"><i class="el-icon-right"></i></div>

                    <div class="box">                      
                        <img v-if="conter.team_icon"  style="width: 30px; height: 30px" :src="urlimg + conter.team_icon" /> 
                        <img  v-else src="@/assets/images/login_bg1.png" />
                        <div class="box_item">
                            <span>{{ conter.team_username }}</span>
                            <span>{{ conter.team_telphone }}</span>
                        </div>
                    </div>

                  </div>
                    <div style="text-align: center;width:50%;margin:auto;margin-top:30px;">
                          <el-button type="primary" class="custom_color_button" style="width:100%;" @click="fictitious_qr_but()">确认</el-button>
                    </div>
                
               </div>
            </el-form>

         

            </div> 
        </el-dialog>

    
      
  </div>
</template>

<script>
import MarketingList from '@/view/Marketing/MarketingList'
export default {
  name: 'marketing',
  data () {
    return {
        datalist:[{"name":"aaaa"}],
        page:1,
        count:0,
        fictitious_mtk:false,
        fictitious_form:{
           phone:'',
           show:false,
        },
        conter:{
          self_icon:'',
          self_telphone:'',
          self_uid:'',
          self_username:'',
          team_icon:'',
          team_telphone:'',
          team_username:'',
        }
    }
  },
 components:{
    MarketingList
  },
  created(){
    this.list_fun()
  },
  mounted (){
    
  },
  methods: {

      list_fun(){
          this.post("/marketer/listOfData", {
              page:this.page, 
	        }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list
            //console.log(res)
         })
      },
      fictitious_but(){
         this.fictitious_mtk = true
     },
     fictitious_search(){
        this.post("/goldbean/selectDetails", {
              telphone:this.fictitious_form.phone,
	        }).then(res => {
              //console.log(res)
              if(res.error_code == 0){
                        this.fictitious_form.show = true
                        this.conter.self_icon = res.result.self_icon
                        this.conter.self_telphone = res.result.self_telphone
                        this.conter.self_uid = res.result.self_uid
                        this.conter.self_username = res.result.self_username
                        this.conter.team_icon = res.result.team_icon
                        this.conter.team_telphone = res.result.team_telphone
                        this.conter.team_username =res.result.team_username
                }else {
                      this.open1(res.message,'warning')
                      this.conter={
                            self_icon:'',
                            self_telphone:'',
                            self_uid:'',
                            self_username:'',
                            team_icon:'',
                            team_telphone:'',
                            team_username:'',
                        }
                      this.fictitious_form.show = false
             }
         })
     },
     fictitious_qr_but(){
        this.post("/marketer/create", {
               uid:this.conter.self_uid,
	        }).then(res => {
                //console.log(res)
             if(res.error_code == 0){
                        this.open1(res.result,'success') 
                        this. conter={
                            self_icon:'',
                            self_telphone:'',
                            self_uid:'',
                            self_username:'',
                            team_icon:'',
                            team_telphone:'',
                            team_username:'',
                        }
                        this.fictitious_form.phone = ''
                        this.fictitious_form.show = false
                        this.fictitious_mtk = false
                        this.list_fun()
                }else {
                      this.open1(res.message,'warning') 
                }

         })
     },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>
.box{
    width: 200px;
    display: flex;
    border: 1px solid #DCDFE6;
    border-radius: 5px;
    padding:10px;
}
.box1{
    width: 200px;
    display: flex;
    padding:0px 10px;
    text-align: center;
}
.box>img{
    width: 50px;
    height: 50px;
    border-radius: 50%;
}
.box_item{
    flex: 1;
    margin-left:10px;
}
.box_item>span{
   display: block;
}
</style>
